//
//  StudentReviewsCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/26.
//

#import "StudentReviewsCell.h"
@interface StudentReviewsCell()

@property(nonatomic,strong) UIImageView *avatarImage;
@property(nonatomic,strong) UILabel *nameLabel;
@property(nonatomic,strong) UILabel *timeLabel;
@property(nonatomic,strong) UILabel *contentLabel;
@property (nonatomic, strong) UIView *lineView;

@end
@implementation StudentReviewsCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
        self.contentView.backgroundColor = rgba(255, 255, 255, 1);
    }
    return self;
}

- (void)setupUI
{
    self.avatarImage = [[UIImageView alloc]initWithFrame:CGRectMake(16, 10, 40, 40)];
    self.avatarImage.backgroundColor = rgba(245, 245, 250, 1);
    self.avatarImage.layer.cornerRadius = 20;
    self.avatarImage.layer.masksToBounds = YES;
    
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.avatarImage.frame)+10, 10, APPwidth-16-CGRectGetMaxX(self.avatarImage.frame), 18)];
    self.nameLabel.font = kPingFangMedium(14);
    self.nameLabel.textColor = rgba(51, 51, 51, 1);
    
    self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.avatarImage.frame)+10, CGRectGetMaxY(self.nameLabel.frame)+4, APPwidth-16-CGRectGetMaxX(self.avatarImage.frame), 18)];
    self.timeLabel.font = kPingFangRegular(12);
    self.timeLabel.textColor = rgba(138, 138, 138, 1);
    
    self.contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(16, CGRectGetMaxY(self.avatarImage.frame)+10, APPwidth-32, 20)];
    self.contentLabel.font = kPingFangRegular(14);
    self.contentLabel.textColor = rgba(51, 51, 51, 1);
    self.contentLabel.numberOfLines = 0;
    
    self.lineView = [[UIView alloc]initWithFrame:CGRectMake(16, 49, APPwidth-30, 1)];
    self.lineView.backgroundColor = rgba(245, 245, 250, 1);
    
    [self.contentView addSubview:self.avatarImage];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.contentLabel];
    [self.contentView addSubview:self.lineView];
    
    
}

-(void)cellFillWithModel:(StudentReviewsModel *)model
{
    self.nameLabel.text = model.ReviewsUserName;
    self.timeLabel.text = model.ReviewsTime;
    self.contentLabel.text = model.ReviewsContent;
    CGFloat contentLabelh = [LongHelper textHeight:model.ReviewsContent WithUIFont:kPingFangRegular(14) AndWidth:APPwidth-32];
    if (contentLabelh < 20) {
        contentLabelh = 20;
    }
    self.contentLabel.frame = CGRectMake(16, CGRectGetMaxY(self.avatarImage.frame)+10, APPwidth-32, contentLabelh);
    self.lineView.frame = CGRectMake(16, CGRectGetMaxY(self.contentLabel.frame)+14, APPwidth-32, 1);
    
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
